package com.rtx.model.dto.response;

import io.swagger.annotations.ApiModelProperty;

import java.util.HashMap;
import java.util.Map;

/**
 * 统一返回结果
 */
public class EdiResponse {
    @ApiModelProperty("返回数据")
    private Map<String,Object> data;

    @ApiModelProperty("响应消息")
    private String returnMgr;

    @ApiModelProperty("响应码")
    private Integer returnCode;

    @ApiModelProperty("认证")
    private Integer token;

    @ApiModelProperty("语言")
    private Integer userLanguage;

    public EdiResponse() {
    }

    public EdiResponse(Integer returnCode, String returnMgr, Integer token, Integer userLanguage) {
        this.returnMgr = returnMgr;
        this.returnCode = returnCode;
        this.token = token;
        this.userLanguage = userLanguage;
    }

    public EdiResponse(Integer returnCode, String returnMgr) {
        this.returnCode = returnCode;
        this.returnMgr = returnMgr;
    }

    public static EdiResponse success(){
        return new EdiResponse(ResultCode.SUCCESS.getCode(),ResultCode.SUCCESS.getMessage());
    }

    public static EdiResponse failed(){
        return new EdiResponse(ResultCode.FAILED.getCode(),ResultCode.FAILED.getMessage());
    }

    public EdiResponse returnCode(Integer returnCode){
        this.setReturnCode(returnCode);
        return this;
    }

    public EdiResponse returnMgr(String returnMgr){
        this.setReturnMgr(returnMgr);
        return this;
    }

    public EdiResponse data(String key,Object value){
        if(this.data == null){
            this.data = new HashMap<>();
        }
        this.data.put(key,value);
        return this;
    }

    @Override
    public String toString() {
        return "EdiResponse{" +
                "data=" + data +
                ", returnMgr='" + returnMgr + '\'' +
                ", returnCode=" + returnCode +
                ", token=" + token +
                ", userLanguage=" + userLanguage +
                '}';
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public String getReturnMgr() {
        return returnMgr;
    }

    public void setReturnMgr(String returnMgr) {
        this.returnMgr = returnMgr;
    }

    public Integer getReturnCode() {
        return returnCode;
    }

    public void setReturnCode(Integer returnCode) {
        this.returnCode = returnCode;
    }

    public Integer getToken() {
        return token;
    }

    public void setToken(Integer token) {
        this.token = token;
    }

    public Integer getUserLanguage() {
        return userLanguage;
    }

    public void setUserLanguage(Integer userLanguage) {
        this.userLanguage = userLanguage;
    }
}
